<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\controller;

/**
 * Description of User
 *
 * @author HHT
 */
use app\controller\Common;
use think\facade\Db;
use app\Request;

class Instorage extends Common {

    //put your code here
    public function index() {



        return view("index", [
            "title" => "入库"
        ]);
    }

    public function save(Request $request) {
       
        $data = $request->param();
      
        $res = Db::name('instorage')->save($data);
        if ($res) {
                  return $res;
        }
    }

    public function show(Request $request) {      
        $limit=$request->param()['limit'];
    
        
        $users = Db::name('instorage')->paginate($limit?$limit:10);
        $list = [];
        $list=$users->items();
        $data = [];
        $data['code'] = 0;
        $data['msg'] = '';
        $data['count'] = $users->total();
        $data['data'] = $list;
        return $data;
    }

    public function delete(Request $request) {

        $id = $request->param('id');
        $res = Db::name('instorage')->delete($id);
        return $res;
    }

    public function update(Request $request) {
        $data = $request->param();
        $res = Db::name('instorage')->update($data);
        if ($res) {
                  return $res;
        }
//        if ($res) {
//            return view("index", [
//                "title" => "用户管理"
//            ]);
//        }
        return $res;
    }

}
